﻿<cfscript>
/** 
* Senate Frameworks termProperty
* 
* @hint "The term property object handler." 
*/ 

component 
	displayname="public.service.handler.termProperty" 
	output=false 
	accessors=true 
	{
		
	/* PROPERTIES */
	property type="boolean" name="Running" default="false" hint="是否当前学期";
	property type="boolean" name="ForCourse" default="false" hint="是否排课学期";
	property type="boolean" name="ForExam" default="false" hint="是否排考学期";
	property type="boolean" name="ForHalfExam" default="false" hint="是否半期排考学期";
	property type="boolean" name="ForChoose" default="false" hint="是否选课学期";
	property type="boolean" name="ForResitExam" default="false" hint="是否补考学期";
	property type="boolean" name="ForCharge" default="false" hint="是否费用结算学期";

	/**
	* @hint "初始化对象"
	* 
	* @Running "是否当前学期"
	* @ForCourse "是否排课学期"
	* @ForExam "是否排考学期"
	* @ForHalfExam "是否半期排考学期"
	* @ForChoose "是否选课学期"
	* @ForResitExam "是否补考学期"
	* @ForCharge "是否费用结算学期"
	*/
	public public.service.handler.termProperty function init( boolean Running=false, boolean ForCourse=false, 
																boolean ForExam=false, boolean ForHalfExam=false, 
																boolean ForChoose=false, 
																boolean ForResitExam=false,
																boolean ForCharge=false ) output=false {
		
		setRunning( arguments.Running );
		setForCourse( arguments.ForCourse );
		setForExam( arguments.ForExam );
		setForHalfExam( arguments.ForHalfExam );
		setForChoose( arguments.ForChoose );
		setForResitExam( arguments.ForResitExam );
		setForCharge( arguments.ForCharge );
		
		return this;
	}
	
	/**
	* @hint "将上述属性转换为属性字符串"
	*/
	public string function stringProperty() output=false {
		
		var prop = "";
		
		/* 执行序列化 */
		if (getRunning()) { prop = prop & "1"; } else { prop = prop & "0"; }

		if (getForCourse()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getForExam()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getForHalfExam()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getForChoose()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getForResitExam()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getForCharge()) { prop = prop & "1"; } else { prop = prop & "0"; }
		
		return prop;
	}
	
	/**
	* @hint "将属性字符串转换为对象属性"
	* 
	* @fString "属性字符串"
	*/
	public void function parseProperty( required string fString ) output=false {
		
		var i = 0;
		
		for (i=1; i <= len(arguments.fString); i++) {
			
			switch (i) {
				
				case 1:
					/* 第1位 是否当前学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setRunning(true); } else { setRunning(false); }
					break;

				case 2:
					/* 第2位 是否排课学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForCourse(true); } else { setForCourse(false); }
					break;
				
				case 3:
					/* 第3位 是否排考学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForExam(true); } else { setForExam(false); }
					break;
				
				case 4:
					/* 第4位 是否半期排考学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForHalfExam(true); } else { setForHalfExam(false); }
					break;
				
				case 5:
					/* 第5位 是否选课学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForChoose(true); } else { setForChoose(false); }
					break;
				
				case 6:
					/* 第6位 是否补考学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForResitExam(true); } else { setForResitExam(false); }
					break;
				
				case 7:
					/* 第7位 是否费用结算学期 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setForCharge(true); } else { setForCharge(false); }
					break;
				
			}
			
		}
		
	}
	
}

</cfscript>